package com.msb.controller;

import com.msb.pojo.BookHb;
import com.msb.service.BookHbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BookHbController {
    @Autowired
    private BookHbService bookHbService;
    @RequestMapping("/findAllHb")
    @ResponseBody
    public String findAll(){
        String name = "";
        List books = bookHbService.findAll();
        for (int i=0;i<books.size();i++){
            BookHb book = (BookHb)books.get(i);
            name = name + book.getName();
        }
        System.out.println("这是hibernate方式");
        return name;
    }
}
